<?php

namespace app\admin\model;
use think\Db;
use think\Model;

class VipModel extends Model
{
    public function getvip()
    {
        $data = Db::table('vip') ->field('id, name, tel, time') ->select();
//        var_dump($data);die;
        return $data;
    }

    public function getshow($id)
    {
        // $data = Db::table(['vip', 'point'])
        //                 ->field('vip.name, vip.id, point.point_count, point.point_order, vip.pay_order')
        //                 ->where(['vip.id' => $id, 'point.vipid' => $id])
        //                 ->select();

        $data = Db::table('vip')
                        ->field('vip.name, vip.id, vip.payorder')
                        ->where(['vip.id' => $id])
                        ->select();
       // var_dump($data);die;
        return $data;
    }

    public function getlevel()
    {
        $data = Db::table('level') ->select();
        return $data;
    }

    public function leveledit($id)
    {
        $data = Db::table('level') ->field('*') ->where('id', $id) ->find();
        return $data;
    }

    public function insertvip()
    {
//        var_dump($_POST);die;
        $data = Db::table('level') ->insert($_POST);
        return $data;
    }

    public function updatelevel()
    {
        unset($_POST['_method']);
//        var_dump($_POST);die;
        $data = Db::table('level') ->where('id', $_POST['id']) ->update($_POST);
        return $data;
    }
}
















